package rpg.map;

import rpg.Rpg;
import square.data.DataGroup;
import square.data.ItemData;

/**
 *
 * @author Pedro Silva Moreira
 */
public class Item extends MapObject {
    
	// Creation
	public Item(String name) {
		this.setDataReflect(DataGroup.findItem(name));
		
		if(this.getDataReflect() == null) {
			return;
		}
		
		ItemData data = this.getDataReflect().instance();
		data.setOwner(this);
		this.setData(data);
	}
	
    // Step Event
    public void onStepIn(MapObject mapObject) {
    	if (Rpg.disableEvents)
			return;
    }

    public void onStepOut(MapObject mapObject) {
    	if (Rpg.disableEvents)
			return;
    }

    // Map Shortcut
    @Override
    public void removeFromMap() {
        if (this.getLocation() != null) {
            this.getLocation().removeItem(this);
        }
    }

    // Get & Set
    @Override
    public ItemData getData() {
        return (ItemData) super.getData();
    }
    
    @Override
    public ItemData getDataReflect() {
        return (ItemData) super.getDataReflect();
    }
}
